package com.ruoyi.common.core.domain;

import io.swagger.models.auth.In;

import java.util.HashMap;

public class AjaxResult<T>  {

    private Integer code;

    private String msg;

    private T data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    private AjaxResult() {

    }

    public static <T> AjaxResult<T> success(T t) {
        AjaxResult<T> result = new AjaxResult<T>();
        result.setData(t);
        result.setCode(0);
        result.setMsg("success");
        return result;
    }
    public static <T> AjaxResult<T> success() {
        AjaxResult<T> result = new AjaxResult<T>();
        result.setData(null);
        result.setCode(0);
        result.setMsg("success");
        return result;
    }

    public static <T> AjaxResult<T> error(String  msg) {
        AjaxResult<T> result = new AjaxResult<T>();
        result.setCode(-1);
        result.setData(null);
        result.setMsg(msg);
        return result;
    }
    public static <T> AjaxResult<T> error() {
        AjaxResult<T> result = new AjaxResult<T>();
        result.setCode(-1);
        result.setData(null);
        return result;
    }

    public static <T> AjaxResult<T> error(Integer code, String msg) {
        AjaxResult<T> result = new AjaxResult<T>();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(null);
        return result;
    }
}
